package com.core.website.api;

import com.core.website.common.Result;
import com.core.website.common.ResultUtil;
import com.core.website.entity.Banner;
import com.core.website.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/bannerApi")
public class BannerApi {

    @Autowired
    private BannerService bannerService;
    @PostMapping("/add")
    public Result add(@RequestBody Banner banner){
        int result=bannerService.add(banner);
        return ResultUtil.success(result);
    }
    @PostMapping("/edit")
    public Result edit(@RequestBody Banner banner){
        int result=bannerService.edit(banner);
        return ResultUtil.success(result);
    }
    @PostMapping("/delete")
    public Result delete(@RequestBody List<String> ids){
        int result=bannerService.delete(ids);
        return ResultUtil.success(result);
    }
    @PostMapping("/queryAll")
    public Result queryAll(@RequestBody Banner banner, HttpServletRequest request){
        List<Banner> result=bannerService.queryAll(banner);
        return ResultUtil.success(result);
    }
    @GetMapping("/queryOne")
    public Result queryOne(String id){
        Banner result=bannerService.queryOne(id);
        return ResultUtil.success(result);
    }
}
